<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>人员统计(单位:件次)</title>

<script type="text/javascript" src="../lib/standalone-framework.js"></script>
<script src="../lib/highcharts.js"></script>
<script type="text/javascript">

function getUrlParam(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		var r = window.location.search.substr(1).match(reg);
		if (r != null)
			return unescape(r[2]);
		return null;
	}
	function get() {
		var projectid = getUrlParam("projectid");
		var beginDate = getUrlParam("beginDate");
		var endDate = getUrlParam("endDate");
		var request = new XMLHttpRequest();
		request.open("GET", "getformatmainrepair.thor?projectid=" + projectid+ "&beginDate=" + beginDate + "&endDate=" + endDate);
		request.onreadystatechange = function() {
			if (request.readyState === 4 && request.status === 200) {
				document.getElementById("load").style.display="none";
				var response = JSON.parse(request.responseText);
				drawChart(response);
			}
		}
		request.send();
	}

	function drawChart(chartData) {
	    var series = chartData.series;
	    if(series.length == 0 ){
			location.href ="reportnodata.thor?reporttype=mrepairer";
		}
		var chart = new Highcharts.Chart({	
			 chart: {
			    renderTo : 'container',
			    type : 'pie',
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
             title: {
                text: '人员统计(单位:件次)'
            },
            tooltip: {
        	    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
            },
			 plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true
                    },
                    showInLegend: true
                }
            },
			series : series
		});
	}
	window.onload = get;
</script>
</head>
<body>
	<div id="container" style="margin: 0 auto"></div>
		<div id="load"  align="center">
			<div id="center" style="position:absolute; left:0; top:120px; width:100%; height:100%; background-color:#FFFFFF; z-index:1000;">
				<table border="0">
					<tr>
						<td><span id="disp" >报表加载中,请等待...</span></td>
					</tr>
				</table>
			</div>
		</div>
</body>
</html>